<!-- search area   -->
<div class="row searchLineWrap">
<form class="form-horizontal" method="post" action="${cxt!}/platform/dict/list" id="searchForm">
  <div class="col-md-12">
	  <div class="row">
	    <div class="col-md-5">
	      <div class="form-group">
	         <label  class="col-md-4 control-label">${_res["systemManage.dictCode"]}</label>
	         <div class="col-md-8">
	            <input type="text" class="form-control" name="dict.l_code" placeholder="${_res['systemManage.dictCode']}" value="${paramMap['dict.l_code']}"/>
	         </div>
	       </div>
	    </div>

	    <div class="col-md-5">
	      <div class="form-group">
	         <label  class="col-md-4 control-label">${_res["systemManage.dictName"]}</label>
	         <div class="col-md-8">
	            <input type="text" class="form-control" name="dict.l_name" placeholder="${_res['systemManage.dictName']}" value="${paramMap['dict.l_name']}"/>
	         </div>
	       </div>
	    </div>	
	    
	    <div class="col-md-2">
	        <div class="form-group">
	          <button type="button" class="btn btn-primary pull-left" onclick="ajaxForm('content','searchForm')">
	          <i class="fa fa-search m-l-sm m-r-xs"></i>${_res["system.search"]}</button>
	        </div>
	    </div>    
	  </div>
  </div>
</form>
</div>
<!-- search area end  -->


<div class="row searchLineWrap">
  <div class="ibox-content">
		<div class="row">
		  <div class="col-md-6 lineSolidRight">
		    <h4>${_res["systemManage.dictList"]}
		    	<% if(hasPrivilegeUrl("dictAdd")){ %>
		    		<a href="#" class="pull-right btn btn-primary fontWeightNormal font1p2rem m-l-md m-b-md" data-toggle="modal" data-target="#dictModalAdd">${_res["systemManage.addDict"]}</a>
		    	<% } %>
		    </h4>
		    <div class="clearfix"></div>
		    <div id="dictWrap">
		       <%include("dictList.html"){}%>
		    </div>
		  </div>
		  
		  
		  <div class="col-md-6">
		    <h4>${_res["systemManage.dictOptionList"]}
		    	<% if(hasPrivilegeUrl("dictItemAdd")){ %>
		    		<a href="#" class="pull-right btn btn-primary fontWeightNormal font1p2rem m-l-md m-b-md" data-toggle="modal" data-target="#dictItemModalAdd">${_res["systemManage.addDictOption"]}</a>
		   		<% } %>
		    </h4>
		    <div class="clearfix"></div>
		    <div id="dictItemWrap">
		       <%include("dictItemList.html"){}%>
		    </div>
		  </div>
		</div>
	</div>
</div>

<#nav />

<!--modal-->
<div class="modal fade" id="dictModalEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<%include("editDict.html"){}%>
</div>
<div class="modal fade" id="dictItemModalEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<%include("editDictItem.html"){}%>
</div>
<div class="modal fade" id="dictModalAdd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<%include("addDict.html"){}%>
</div>
<div class="modal fade" id="dictItemModalAdd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<%include("addDictItem.html"){}%>
</div> 

<script>
$(document).ready(function(){
	//增加模拟框拖动效果
	$(".modal").draggable({
	    handle: ".modal-header"
	});
});


/*model  动态控制    新增字典  初始化值*/ 
function dictModalAdd(){	  
		$('#dictModalAdd').on('show.bs.modal', function (event) {
			 var dictCode = $("input[name='dict.code']");
			 var dictName = $("input[name='dict.name']");
			 var dictRemark = $("input[name='dict.remark']");
			// init input value
			 dictCode.val("");
			 dictName.val("");
			 dictRemark.val("");
			 // clear validate style
			 clearValidateStyle(dictCode);
			 clearValidateStyle(dictName);
		})
}
dictModalAdd();


/*model  动态控制    新增字典项  初始化值*/ 
function dictItemModalAdd(){	  
		$('#dictItemModalAdd').on('show.bs.modal', function (event) {
			 var dictItemValue = $("input[name='dictItem.value']");
			 var dictItemName = $("input[name='dictItem.name']");
			 var dictItemNameen = $("input[name='dictItem.nameen']");
			 var dictItemRemark = $("input[name='dictItem.remark']");
			 // init input value
			 dictItemValue.val("");
			 dictItemName.val("");
			 dictItemNameen.val("");
			 dictItemRemark.val("");
			 // clear validate style
			 clearValidateStyle(dictItemValue);
			 clearValidateStyle(dictItemName);
			 clearValidateStyle(dictItemNameen);
			 clearValidateStyle(dictItemValue);
		})
}
dictItemModalAdd();


/*model  动态控制    字典编辑 传递值*/ 
function dictModalEdit(){	  
		$('#dictModalEdit').on('show.bs.modal', function (event) {
			var button = $(event.relatedTarget); // Button that triggered the modal
			var dictId = button.data('whatever'); // Extract info from data-* attributes
			var td1Text_code=button.parents("tr").find("td").eq(0).text();
			var td2Text_name=button.parents("tr").find("td").eq(1).text();
			var td3Text_remark=button.parents("tr").find("td").eq(2).text();
			
			var modal = $(this);
			var dict_id_element = modal.find('.modal-body #dict_id');
			var dict_code_element = modal.find('.modal-body #dict_code');
			var dict_name_element = modal.find('.modal-body #dict_name');
			var dict_remark_element = modal.find('.modal-body #dict_remark');
			// init value
			modal.find('.modal-title').text('编辑 (' + td1Text_code +')');
			dict_id_element.val(dictId);
			dict_code_element.val(td1Text_code);
			dict_name_element.val(td2Text_name);
			dict_remark_element.val(td3Text_remark);
			
			// clear validate style
			clearValidateStyle(dict_name_element);
		})
}
dictModalEdit();

/*model  动态控制    字典项编辑 传递值*/
function dictItemModalEdit(){	  
	$('#dictItemModalEdit').on('show.bs.modal', function (event) {
		var button = $(event.relatedTarget); // Button that triggered the modal
		var dictItem_id = button.data('whatever'); // Extract info from data-* attributes
		var td1Text_name=button.parents("tr").find("td").eq(0).text();
		var td2Text_nameen=button.parents("tr").find("td").eq(1).text();
		var td3Text_value=button.parents("tr").find("td").eq(2).text();
		
		var modal = $(this);
		var dictItem_id_element = modal.find('.modal-body #dictItem_id');
		var dictItem_code_element = modal.find('.modal-body #dictItem_code');
		var dictItem_name_element = modal.find('.modal-body #dictItem_name');
		var dictItem_nameen_element = modal.find('.modal-body #dictItem_nameen');
		var dictItem_value_element = modal.find('.modal-body #dictItem_value');
		var dictCode = $("#dictCode").val();
		// init value
		modal.find('.modal-title').text('编辑 (' + dictCode +')');
		dictItem_id_element.val(dictItem_id);
		dictItem_code_element.val(dictCode);
		dictItem_name_element.val(td1Text_name);
		dictItem_nameen_element.val(td2Text_nameen);
		dictItem_value_element.val(td3Text_value);
		
		// clear validate style
		clearValidateStyle(dictItem_name_element);		
		clearValidateStyle(dictItem_nameen_element);	
		clearValidateStyle(dictItem_value_element);
	})
}
dictItemModalEdit();	  
</script>